package com.bawei.model_sevent.Activity.Banner;

import android.util.Log;

import com.bawei.model_sevent.Activity.Http.APl;
import com.bawei.model_sevent.Activity.Http.Http_Slings;

import org.jetbrains.annotations.NotNull;

import java.util.List;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * 时间：2021/11/16 14:58.
 * 类名：BannerModel
 * 作用：Model_sevent
 * 作者:张羽_zy
 */
public class BannerModel implements BannerContent.Model{
    

    @Override
    public void onSuccess(String s1, String s2, BannerCallBack bannerCallBack) {
        Http_Slings.getInstance().getDate("http://82.156.178.182:8082/")
                .create(APl.class)
                .bannerList(s1,s2)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new Observer<BannerBean>() {
                    @Override
                    public void onSubscribe(@NotNull Disposable d) {

                    }

                    @Override
                    public void onNext(@NotNull BannerBean bannerBean) {
                        List<BannerBean.DataBean> data = bannerBean.getData();
                        bannerCallBack.onSuccess(data);
                    }

                    @Override
                    public void onError(@NotNull Throwable e) {
                        Log.i("a1aaa", "onError: "+e.getMessage());
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
    @Override
    public void DesTroy() {

    }
}
